package com.xy.bizportdemo.task;

import android.content.Context;
import android.util.Log;

import com.xy.bizportdemo.util.ImportDataUtil;

import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Created by admin on 2016/11/26.
 */

public class LoadXmlAsyncTask extends LoadBaseAsyncTask {
    private static final String TAG = "LoadXmlAsyncTask";

    public LoadXmlAsyncTask(Context context) {
        super(context);
    }

    @Override
    protected Void doInBackground(String... params) {
        InputStream is = null;
        try {
            is = new FileInputStream(mXmlPath);
            ImportDataUtil.importData(mContext, is);
        } catch (Throwable t) {
            mStatus = STATUS_ERROR;
            Log.e(TAG, "doInBackground", t);
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (Throwable t) {
                Log.e(TAG, "doInBackground close", t);
            }

            return super.doInBackground(params);
        }
    }


    private String mXmlPath = null;
    public void setPath(String path) {
        mXmlPath = path;
    }
}
